package com.robusta.spreadsheet.describe.jaxb.validation;

import com.robusta.spreadsheet.describe.Validatable;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

import static com.google.common.base.Strings.isNullOrEmpty;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType
public class MandatoryValidator extends BaseValidator {
    @Override
    public void validate(Validatable validatable) throws ValidationException {
        if(isNullOrEmpty(validatable.getInput())) {
            throw new ValidationException("A non empty input is required.", validatable);
        }
    }
}
